<?

	$base= "ucg - copia";

		$tabla = "compra1";

	$conexion=mysql_connect("localhost","root","");

	mysql_select_db($base,$conexion);

	$resultado=mysql_query("SELECT * FROM $tabla WHERE cod_c='$Modificar'",$conexion);

	$registro = mysql_fetch_row($resultado);

	?><title>Consulta Compras</title>
 <style type="text/css">
<!--
.Estilo1 {color: #000000}
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #000000;
}
body {
	background-color: #FFFFFF;
}
a {
	font-family: Courier New, Courier, mono;
	font-size: 14px;
	color: #000000;
}
a:visited {
	color: #000000;
}
a:hover {
	color: #000000;
}
a:active {
	color: #999999;
}
-->
 </style>
<link href="boton.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
@import url("tablas.css");
a:link {
	color: #000000;
}
.style5 {
	font-size: 14px;
	font-weight: bold;
	color: #000000;
}
.style9 {
	color: #000000;
	font-weight: bold;
}
.style4 {font-size: 12px}
.style12 {font-size: 14px; color: #000000; }
-->
</style>
<table width="100%" border="1" bordercolor="#000000">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
  <tr>
    <td>Fecha:</td>
    <td colspan="4" ><? echo "$registro[3]";?></td>
  </tr>
  <tr>
    <td height="21" colspan="5">Mediante la presente se emite <strong>ORDEN DE COMPRA</strong> interna a la empresa </td>
  </tr>
  <tr>
    <td><strong>Empresa:</strong></td>
    <? $resul=mysql_query("SELECT emp FROM proveedor WHERE rif='$registro[4]'",$conexion);

	$regis = mysql_fetch_row($resul); ?>
    <td colspan="4"><? echo "$regis[0]";?></td>
  </tr>
  <tr>
    <td><strong>Rif:</strong></td>
    <td colspan="4"><? echo "$registro[4]";?></td>
  </tr>
  <tr>
    <td height="27"><div align="center"><strong>Cantidad</strong></div></td>
    <td width="54%"><div align="center"><strong>Descripci&oacute;n</strong></div></td>
    <td width="11%"><div align="center"><strong>Precio U </strong></div></td>
    <td width="8%"><div align="center">
    <div align="center"><strong>Iva</strong></div></td>
    <td width="15%"><div align="center"><strong>Total</strong></div></td>
  </tr>
  <? $resu=mysql_query("SELECT * FROM  id_compra WHERE cod_c='$registro[0]'",$conexion);

	while ($reg= mysql_fetch_row($resu)) { 	?>
  <tr bordercolor="#000000">
    <td align="center"><? echo "$reg[2]";?></td>
    <td><? echo "$reg[3]";?></td>
    <td align="right" valign="middle"> 
    <? echo "$reg[4]";?>    </td>
    <td align="right" valign="middle"><? echo "$reg[7]";?></td>
    <td align="right" valign="middle">
    <? $totaluni=$reg[2]*$reg[4]; echo $totaluni; ?></td>
  </tr>
  <? $subtotal=$subtotal+$totaluni; } ?>
  <tr>
    <td colspan="2" ></td>
    <td colspan="2" ><div align="right">SUB - TOTAL</div></td>
    <td align="right" valign="middle" bordercolor="#000000" >
      <?  echo $subtotal; ?>    </td>
  </tr>
  <? 
  
  
  $re=mysql_query("SELECT sum(cantidad*pre_unit),iva FROM  id_compra WHERE cod_c='$registro[0]' and iva!='0' group by iva",$conexion);

	while ($iva= mysql_fetch_row($re)) { 
	
	?>
  <tr>
    <td colspan="2" ></td>
    <td colspan="2" ><div align="right">IVA <? echo "$iva[1]";?> %</div></td>
    <td align="right" valign="middle" bordercolor="#000000">
      <? $totaliva=($iva[0])*($iva[1]/100); echo $totaliva; ?>    </td>
  </tr>
  <? $totaliva1=$totaliva1+$totaliva; } ?>
  <tr>
    <td colspan="2" ></td>
    <td colspan="2" ><div align="right"><strong>TOTAL Bs.</strong></div></td>
    <td align="right" valign="middle" bordercolor="#000000" >
      <? $total=$subtotal+$totaliva1; echo $total; ?>    </td>
  </tr>
  
  <tr>
    <td height="28" ><div align="center">Elaborado Por: </div></td>
    <td><div align="center">Aprobado Por: </div></td>
    <td colspan="3" ><div align="center">Recibido Por: </div></td>
  </tr>
  <tr>
    <td ><div align="center"></div></td>
    <td ><div align="center"></div></td>
    <td colspan="3"  ><div align="center"></div></td>
  </tr>
  <tr>
    <td ><div align="center">&nbsp;</div></td>
    <td ><div align="center">&nbsp;</div></td>
    <td colspan="3"><div align="center">&nbsp;</div></td>
  </tr>
  <tr>
    <td ><div align="center"></div></td>
    <td ><div align="center"></div></td>
    <td colspan="3"><div align="center"></div></td>
  </tr>
  <tr>
    <td ><div align="center"><? echo "$registro[6]";?></div></td>
    <td ><div align="center"><? echo "$registro[7]";?></div></td>
    <td colspan="3"><div align="center">&nbsp;</div></td>
  </tr>
  <tr>
    <td><div align="center">Administradora de la Unidad </div></td>
    <td><div align="center">Jefe de la Unidad </div></td>
    <td colspan="3">
      <div align="justify">
    <div align="center">Firma y Sello    </div></td>
  </tr>
</table>
</HTML>
